"""
__project__ = 'thc'
__file_name__ = '练习'
__author__ = 'thc'
__time__ = '2020/12/21/021 15:46'
__product_name = PyCharm
-*- coding:utf-8 -*-
"""

from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
import os
"""
# driver = webdriver.Chrome()
# driver.get('https://www.baidu.com')
# driver.maximize_window()
# driver.find_element_by_xpath('kw').clear()
# driver.find_element_by_id('kw').send_keys('微信')
# driver.find_element_by_id('su').click()
# sleep(3)
# driver.quit()

driver = webdriver.Chrome()
path = os.path.dirname(os.path.abspath(__file__))
file_path = 'file:///' + path + '/forms.html'
driver.get(file_path)
name = driver.find_element_by_xpath('//input[@name="username"]')
name.send_keys('admin')
pwd = driver.find_element_by_css_selector('#pwd')
pwd.send_keys('123')
print(name.get_attribute('value'))
print(pwd.get_attribute('value'))
driver.find_element_by_id('submit').click()
sleep(3)
driver.switch_to.alert.accept()
name.clear()
pwd.clear()
sleep(3)
driver.quit()

driver = webdriver.Chrome()
path1 = os.path.dirname(os.path.abspath(__file__))
file_path1 = "file:///" + path1 + '/forms2.html'
driver.get(file_path1)
swimming = driver.find_element_by_name('swimming')
reading = driver.find_element_by_name('reading')
swimming.click()
reading.click()

lst = driver.find_elements_by_name('gender')
lst[0].click()
sleep(2)
lst[1].click()
sleep(1)
driver.find_element_by_xpath('//input[contains(@value,"Login")]').click()
sleep(3)
driver.switch_to.alert.accept()
sleep(1)
driver.quit()
"""

# driver = webdriver.Chrome()
# driver.get('https://www.baidu.com')
# driver.find_element_by_id('kw').send_keys('微信')
# driver.find_element_by_xpath('//input[contains(@value,"百度一下")]').click()
# sleep(3)
# driver.find_element_by_xpath('//div[@id="2"]/h3/a').click()
# sleep(3)
# driver.quit()

# driver = webdriver.Chrome()
# driver.get('http://127.0.0.1/news/')
# driver.find_element(By.NAME, 'Submit2').click()
# driver.find_element(By.XPATH, '//input[@name="groupid][0]').click()

# driver = webdriver.Chrome()
# driver.maximize_window()
# file_dir = os.path.dirname(os.path.abspath(__file__))
# url = file_dir + '/forms2.html'
# driver.get(url)
# sleep(2)
# driver.find_elements(By.XPATH, '//input[@name = "gender"]')[0].click()
# # driver.find_element_by_xpath('//form[@text()="swimming"]/input[2]').click()
# # list[0].click()
# sleep(2)
# driver.quit()

driver = webdriver.Chrome()
driver.maximize_window()
driver.get('http://localhost/news/')
sleep(2)
driver.find_element_by_name('Submit2').click()
sleep(2)
# driver.find_element(By.XPATH, '/html/body/table[4]/tbody/tr/td[2]/table/tbody/tr[3]/td/input').click()
driver.find_element_by_xpath("/html/body/table[1]/tbody/tr/td[2]/table/tbody/tr[2]/td[1]/a[1]").click()
# driver.find_element_by_xpath('//form[@text()="swimming"]/input[2]').click()
# list[0].click()
sleep(2)
driver.quit()

# /html/body/table[4]/tbody/tr/td[2]/table/tbody/tr[3]/td/input
# /html/body/table[4]/tbody/tr/td[2]/table/tbody/tr[3]/td/input

# /html/body/table[1]/tbody/tr/td[2]/table/tbody/tr[2]/td[1]/a[1]







